//
//  GYHMainController.swift
//  SinaWeibo-18
//
//  Created by 高勇华 on 15/9/29.
//  Copyright © 2015年 高勇华. All rights reserved.
//

import UIKit

class GYHMainController: UITabBarController {

    @IBOutlet weak var MainTabBar: GYHTabBar!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

       //监听中间button的点击事件
        MainTabBar.middleButton.addTarget(self, action: "DidCilckMiddleButton", forControlEvents: UIControlEvents.TouchUpInside)
        
        
        loadControllers()
        
    }
//实现点击方法
    func DidCilckMiddleButton(){
    
    
    print("你点我干嘛")
        
//    let view = UIView(frame: UIScreen.mainScreen().bounds)
//
//    view.backgroundColor = UIColor.orangeColor()

    
        
        
    
    }
    //加载所有控制器
    func loadControllers(){
        
       
    
        loadControll("Home", title: "首页", imageName:"tabbar_home")
        loadControll("Discover", title: "发现", imageName:"tabbar_discover")
        loadControll("Message", title: "信息", imageName:"tabbar_message_center")
        loadControll("Profile", title: "我", imageName:"tabbar_profile")

        
        
    
    }
    
    //加载单个控制器
    func loadControll(sbName:String,title:String,imageName:String){
    
   let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let vc = sb.instantiateInitialViewController() as!UINavigationController
        
//        vc.title = title
        
        vc.topViewController?.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
        
        addChildViewController(vc)
        
        
        
    }
    
    
    
    
    

}
